home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows5 / winnet.zip / 8259.NOT < prev    next >
Internet Message Format  |  1990-07-26  |  8KB

  1. From nelson@sun.soe.clarkson.edu Thu Jul 26 15:25:24 1990
  2. Received: from omnigate.clarkson.edu by pear.ecs.clarkson.edu with SMTP
  3.     id AA2818 ; Thu, 26 Jul 90 15:25:23 GMT
  4. Received: from sun.soe.clarkson.edu by omnigate.clarkson.edu id aa09445;
  5.           26 Jul 90 15:14 EDT
  6. Received: by sun.soe.clarkson.edu (4.1/SMI-4.0)
  7.     id AA01795; Thu, 26 Jul 90 15:14:20 EDT
  8. Message-Id: <9007261914.AA01795@sun.soe.clarkson.edu>
  9. Return-Path: <@po5.andrew.cmu.edu:ddp+@andrew.cmu.edu>
  10. Date: Fri, 20 Jul 90 04:18:41 -0400 (EDT)
  11. From: Drew Daniel Perkins <ddp+@andrew.cmu.edu>
  12. To: nelson@sun.soe.clarkson.edu
  13. Subject: Re: 
  14. In-Reply-To: <2802@pear.ecs.clarkson.edu>
  15. References: <2802@pear.ecs.clarkson.edu>
  16.  
  17. nelson@pear.ecs.clarkson.edu writes:
  18. > Why?
  19. >         in      al,dx                   ;get master mask
  20. >         and     al,not (1 shl 2)        ; and clear slave cascade bit in mask
  21. >         out     dx,al                   ;set new master mask (enable slave int)
  22.  
  23. That solves a bug that I'm truly amazed that you haven't run into
  24. before (I'm equally amazed that it exists).  We have a few very old
  25. original IBM PC/AT's (the one's with the strange piggybacked 256KB
  26. DRAMS which together made 512KB).  It seems that the BIOS on those old
  27. versions does NOT initialize the master 8259 for you so that the slave
  28. 8259 can interrupt.  If you want it to (i.e. if you want to use int
  29. 8-15), you had better make sure that the bit is cleared.  The obvious
  30. outcome is that you don't get interrupts and the packet driver doesn't
  31. work.  I think the reason that you didn't see this is that you didn't
  32. really have any cards that supported ints 8-15 (atleast not WD varieties).
  33. In any case, these three instructions shouldn't ever cause anyone any harm.
  34.  
  35. Drew
  36.  
  37.  
  38. From nelson@sun.soe.clarkson.edu Thu Jul 26 15:42:53 1990
  39. Received: from omnigate.clarkson.edu by pear.ecs.clarkson.edu with SMTP
  40.     id AA2821 ; Thu, 26 Jul 90 15:42:52 GMT
  41. Received: from sun.soe.clarkson.edu by omnigate.clarkson.edu id aa09631;
  42.           26 Jul 90 15:31 EDT
  43. Received: by sun.soe.clarkson.edu (4.1/SMI-4.0)
  44.     id AA02405; Thu, 26 Jul 90 15:31:25 EDT
  45. Message-Id: <9007261931.AA02405@sun.soe.clarkson.edu>
  46. Return-Path: <ddp+@andrew.cmu.edu>
  47. Date: Tue, 12 Jun 90 00:56:40 -0400 (EDT)
  48. From: Drew Daniel Perkins <ddp+@andrew.cmu.edu>
  49. To: pcip@twg.com, drivers@sun.soe.clarkson.edu
  50. Subject: Dell System 325 hardware bug
  51.  
  52. I seem to have run into a a real hardware bug in the Dell System 325
  53. Chips & Technologies 8259 clone interrupt controller.
  54.  
  55. Summary:
  56.  
  57. Sending this interrupt controller a Non Specific End of Interrupt
  58. (EOI) command causes it to reset all In Service Register (ISR) bits
  59. instead of only the most recent one with the highest priority.
  60.  
  61. Long Winded Explanation:
  62.  
  63. I had a serious bug with my high-performance Western Digital wd80x3
  64. packet driver.  Transmitting and receiving on it at high rates caused
  65. it to go west in many different ways.  After tearing my hair out for a
  66. while, I added logging code which logged all procedure entries and
  67. exits along with detailed chip status in a large ring.  I finally
  68. discovered that the impossible was happening.  During my packet copy
  69. routine (which can take > 1.5ms to copy a 1500 byte packet), my
  70. interrupt handler was being reentered and was trashing the stack.
  71. This "shouldn't happen" since I was not giving an EOI command to the
  72. interrupt controller until the very end of the interrupt handler.  The
  73. interrupt did however reenable processor and ethernet chip interrupts
  74. fairly early.
  75.  
  76. After tearing my hair out some more and checking my code thouroughly,
  77. I decided that I must be getting some other interrupt in the middle of
  78. my code somewhere.  I added some more logging code to record interrupt
  79. controller status, and changed my packet copy routine to enable
  80. processor interrupts AFTER the copy instead of before it.  Sure
  81. enough, at the point the bug hit, my log indicated that timer had
  82. fired and a timer interrupt was now pending.  Also, I had received a
  83. new packet, and the ethernet chip also had a new interrupt pending
  84. although it was still blocked because it already had an interrupt in
  85. service.  However, immediately after reenabling processor interrupts,
  86. my log indicated that my interrupt handler was reentered.  This
  87. indicated to me that the timer interrupt handler was somehow resetting
  88. not only its ISR bit but mine also.
  89.  
  90. After disassembling the timer interrupt handler, I determined that the
  91. only thing it was doing was sending a Non Specific EOI to the primary
  92. interrupt controller (using mov al,20h; out 20h,al).  To make my case
  93. for a hardware bug even stronger, I next coded my own timer interrupt
  94. handler.  Just before and just after the mov/out instructions, I made
  95. log entries.  Sure enough, while my log showed the ISR register
  96. reading 21h (IR5 and IR0 in service) just before the EOI was sent, it
  97. read 0 just after.  I then changed the code to use a specific EOI
  98. instruction to reset the timer interrupt instead of a non specific
  99. EOI.  The problem went away!
  100.  
  101. Finally, I tested the code with a non specific EOI on a stock IBM
  102. PC/AT with a real Intel 8259.  It didn't exhibit the problem.
  103.  
  104. Since I can't change the real timer interrupt handler (its in BIOS), I
  105. had to use a different workaround.  Just before reenabling processor
  106. interrupts, I now disable further ethernet device interrupts by
  107. setting its Interrupt Mask Register (IMR) bit.  At the end of
  108. interrupt handler, I reset the bit.  This insures that I can't get
  109. further device interrupts even if the timer interrupt clears my ISR bit.
  110.  
  111. Synopsis:
  112.  
  113. If you write high performance drivers where:
  114. 1.  The interrupt handler runs with other interrupts enabled at the
  115. processor and at the interrupt controller,
  116. 2.  The interrupt handler reenables interrupts at the device while 1.
  117. is true and further device interrupts are possible before the
  118. interrupt handler again disables interrupts and returns,
  119. 3.  You want to the driver to work in clones with C&T chips
  120.  
  121. Then, you better use a technique like the one I use to guarantee that
  122. you can't get reentrant interrupts.
  123.  
  124. Drew
  125.  
  126.  
  127. From nelson@sun.soe.clarkson.edu Thu Jul 26 15:43:12 1990
  128. Received: from omnigate.clarkson.edu by pear.ecs.clarkson.edu with SMTP
  129.     id AA2822 ; Thu, 26 Jul 90 15:43:11 GMT
  130. Received: from sun.soe.clarkson.edu by omnigate.clarkson.edu id aa09633;
  131.           26 Jul 90 15:31 EDT
  132. Received: by sun.soe.clarkson.edu (4.1/SMI-4.0)
  133.     id AA02415; Thu, 26 Jul 90 15:31:47 EDT
  134. Message-Id: <9007261931.AA02415@sun.soe.clarkson.edu>
  135. Return-Path: <nelson>
  136. Date: Wed, 13 Jun 90 10:16:38 EDT
  137. To: drivers@sun.soe.clarkson.edu
  138. From: Drew Daniel Perkins <ddp+@andrew.cmu.edu>
  139. Sender: nelson@sun.soe.clarkson.edu
  140. In-Reply-To: <9006120558.AA14002@endor.harvard.edu>
  141. Subject: Re: Dell System 325 hardware bug
  142. Reply-To: nelson@clutx.clarkson.edu
  143.  
  144. ddl@das.harvard.edu (Dan Lanciani) writes:
  145. >         Do you have a little demo program I can rty on machines?
  146.  
  147. Unfortunately, no I don't.  Producing the bug took a lot of effort
  148. including 1 machine (a router) with two interfaces and two other
  149. machines pinging each other through the first.  To generate enough
  150. traffic, the first machine had a packet exploder which generated 50
  151. packets for every one going through it.
  152.  
  153. I certainly believe that it should be possible to write a much simpler
  154. program to generate the bug, but I definitely don't have time to try
  155. it...  I guess what I would do is write a program that would:
  156.  
  157. 1.  Initialize a "reentered" variable to zero.
  158. 2.  Cause some device to generate an interrupt.
  159. 3.  Have the interrupt handler check the "reentered" variable.  If it
  160.     is equal to zero, continue to 4.  Else, goto 8.
  161. 4.  Reset the interrupt at the device.
  162. 5.  Cause the device to generate another interrupt.  4 and 5 must be
  163.     done in this order to get the interrupt controller's edge
  164.     trigger latch to be set.
  165. 6.  Reenable processor interrupts.  Do NOT reenabled interrupt
  166.     controller interrupts.  I.e. do NOT send an EOI.
  167. 7.  Wait in a infinite loop.  Higher priority (i.e. timer) interrupts
  168.     should be able to occur but interrupts from this device should not.
  169. 8.  Print "bad interrupt controller".  If you got here then a timer
  170.     interrupt fired and managed to reenable your device interrupts
  171.     by doing a Non Specific EOI to a broken interrupt controller.
  172.  
  173. Drew
  174.  
  175.  
  176.  
  177.